﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK;
using OpenTK.Graphics.OpenGL4;
using OpenTK.Input;
using System.Drawing;
using OpenTK.Graphics;

namespace TestOpenTk3._0 {
    class MyGameWindow30 : GameWindow {
        public MyGameWindow30() {
            this.Load += MyGameWindow_Load;
            this.Resize += MyGameWindow_Resize;
            this.RenderFrame += MyGameWindow_RenderFrame;
            this.Unload += MyGameWindow_Unload;
            this.Width = 1280;
            this.Height = 720;

        }


        private void MyGameWindow_RenderFrame(object sender, FrameEventArgs e) {
            GL.ClearColor(.1f, .1f, .99f, .9f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            Render();

            SwapBuffers();
            ProcessEvents();
        }

        private void MyGameWindow_Load(object sender, EventArgs e) {

            VSync = VSyncMode.Off;
            GL.Enable(EnableCap.DepthTest);
        }

        MouseDevice mouseDev = new MouseDevice();
        private void Render() {
            MouseState state = this.mouseDev.GetCursorState();
            var WindowsCursor = System.Windows.Forms.Cursor.Current;
            var clientPos = PointToClient(new Point(state.X, state.Y));
            Console.WriteLine($"mouseState:{state.X},{state.Y} clientPos:{clientPos} gamewindow.Mouse:{this.mouseDev.X},{this.mouseDev.Y}\t windows cursor:{System.Windows.Forms.Cursor.Position}\t ");
            //this.Cursor
            
        }

        private void MyGameWindow_Resize(object sender, EventArgs e) {
            GL.Viewport(0, 0, Width, Height);
        }



        private void MyGameWindow_Unload(object sender, EventArgs e) {
            //shader.Dispose();
        }

    }
}
